package com.graduation.vaccine.controller;


import com.graduation.vaccine.service.IAppointmentService;
import com.graduation.vaccine.vo.AppointmentVo;
import com.graduation.vaccine.vo.DataListVo;
import com.graduation.vaccine.vo.RespBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhaoJunYao
 * @since 2022-04-22
 */
@Controller
@RequestMapping("/appointment")
@Api(tags = "订单模块")
public class AppointmentController {

    @Autowired
    private IAppointmentService appointmentService;

    @ApiOperation("根据手机号获取用户的所有订单")
    @ResponseBody
    @PostMapping("/list/phone")
    public RespBean getListByPhone(@RequestBody String phone){
        return appointmentService.getListByPhone(phone);
    }

    @ApiOperation("提交预约订单")
    @ResponseBody
    @PostMapping("/add")
    @Transactional(rollbackFor = Exception.class)
    public RespBean addOne(@RequestBody AppointmentVo appointmentVo) throws ParseException {
        return appointmentService.addOne(appointmentVo);
    }
     @ApiOperation("可预约时间")
    @ResponseBody
    @PostMapping("/datalist")
    public RespBean getDataList(@RequestBody DataListVo dataListVo) throws ParseException {
        return appointmentService.getDataList(dataListVo);
     }



}
